package client.construct.polymorphic_factory;

import org.junit.Test;
import org.xml.sax.SAXException;
import uml.construct.polymorphic_factory.Logger;
import uml.construct.polymorphic_factory.LoggerFactory;
import util.bean.BeanUtil;
import util.xml.XMLUtil;

import javax.xml.parsers.ParserConfigurationException;
import java.io.File;
import java.io.IOException;

/**
 * 工厂方法（多态工厂、虚拟构造器）：客户端根据抽象工厂和抽象产品编程，是很多开源框架和API类库的核心模式<br>
 * 1.客户端不知道它所需要的对象的类,只需要知道创建产品的工厂，可将具体工厂的信息存储在配置文件或者数据库中，结合反射得到工厂实例<br>
 * on 2022/12/15 0:42
 */
public class Client {
    @Test
    public void t() throws ClassNotFoundException, InstantiationException, IllegalAccessException, ParserConfigurationException, IOException, SAXException {
        LoggerFactory loggerFactory = BeanUtil.newBean(
                LoggerFactory.class,
                new File("src/main/resources/xml/polymorphic_factory.xml"),
                "factoryFullName");
        Logger logger = loggerFactory.constructLogger();
        logger.log();
    }
}
